<?php namespace Home\Controller; 

use Hdphp\Controller\Controller;

//测试控制器
class IndexController extends Controller{

	//模板目录
	protected $tpl;
	//构造函数
	public function __init()
	{
		//path
		$this->tpl = 'template/'.C('web.style');
	}
	
    //网站首页
    public function index(){
       View::make($this->tpl.'/index.html');
    }

    //新闻页
    public function news(){
       View::make($this->tpl.'/news.html');
    }

    //新闻详情页
    public function news_detail(){
       View::make($this->tpl.'/news_detail.html');
    }

    //产品页
    public function product(){
       View::make($this->tpl.'/product.html');
    }

    //产品详情页
    public function product_detail(){
       View::make($this->tpl.'/product_detail.html');
    }

    //解决方案
    public function jiejuefangan(){
       View::make($this->tpl.'/jiejuefangan.html');
    }


    //栏目列表页
    public function category()
    {
    	$id = Q('get.id',0,'intval');
    	$field = Db::table('category')->where('id',$id)->first();
    	View::with('cms',$field);
    	View::make($this->tpl.'/category.html');
    }

    // public function article()
    // {
    //     $id = Q('id',0,'intval');
    //     $article = Db::table('article a')->where('a.id','=',$id)->first();
    //     $category = Db::table('category')
    //     ->where('id','=',$article['cid'])
    //     ->first();
    //     $cms=$article;
    //     $cms['category']=$category;
    //     View::with('cms',$cms)->make($this->tpl.'/article.html');
    //
    // }
    
    public function article()
    {
        $id = Q('get.id',0,'intval');
        $article = Db::table('article a')->where('a.id','=',$id)->first();
        $category = Db::table('category')
        ->where('id','=',$article['cid'])
        ->first();
        $cms=$article;
        $cms['category']=$category;
        View::with('cms',$cms)->make($this->tpl.'/news_detail.html');
    }
}









